/*
 Navicat MySQL Data Transfer

 Source Server         : localhost
 Source Server Type    : MySQL
 Source Server Version : 80022
 Source Host           : localhost:3306
 Source Schema         : jvav

 Target Server Type    : MySQL
 Target Server Version : 80022
 File Encoding         : 65001

 Date: 19/03/2021 15:09:59
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for article
-- ----------------------------
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
  `id` int NOT NULL AUTO_INCREMENT,
  `uid` int DEFAULT NULL,
  `agree` int DEFAULT '0',
  `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文章标题',
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `date` timestamp NOT NULL,
  `image` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '文章封面',
  `star` int DEFAULT '0',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `uid` (`uid`) USING BTREE,
  CONSTRAINT `article_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of article
-- ----------------------------
BEGIN;
INSERT INTO `article` VALUES (1, 1, 6, '栈和队列的转换上', '@[TOC](超易理解的栈和队列)\r\n## 栈和队列的转换上\r\n我们通过一系列栈的压入和弹出操作来分析用两个队列模拟-一个栈的过程。如图所示，去满五年先在queue1中压入abc三个元素，只要有进队 ，必压入queue1中     弹出的时候   若queue2为空，则吧queue1中的元素依次弹出并压入queue2中   此时queue2中只要弹出元素   必是和压入顺序一致  即先进先出\r\n\r\n\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200405085413391.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n话不多说  上代码 \r\n\r\n\r\n\r\n\r\nclass MyQueue {\r\npublic:\r\n    /** Initialize your data structure here. */\r\n    stack<int> s1;\r\n    stack<int> s2;\r\n    MyQueue() {\r\n\r\n    }\r\n    \r\n    /** Push element x to the back of queue. */\r\n    void push(int x) {\r\n        s1.push(x);\r\n    }\r\n    \r\n    /** Removes the element from in front of queue and returns that element. */\r\n    int pop() {\r\n        if(s2.size()==0)\r\n        {\r\n            while(s1.size()!=0)\r\n            {\r\n                s2.push(s1.top());\r\n                s1.pop();\r\n            }\r\n        }\r\n        int res=s2.top();\r\n        s2.pop();\r\n        return res;\r\n    }\r\n    \r\n    /** Get the front element. */\r\n    int peek() {\r\n        if(s2.size()==0)\r\n        {\r\n            while(s1.size()!=0)\r\n            {\r\n                s2.push(s1.top());\r\n                s1.pop();\r\n            }\r\n        }\r\n        int res=s2.top();\r\n        \r\n        return res;\r\n    }\r\n    ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200405090159472.png)\r\n    /** Returns whether the queue is empty. */\r\n    bool empty() {\r\n        if(s1.empty()&&s2.empty())\r\n            return true;\r\n        return false;\r\n    }\r\n};\r\n\r\n\r\n关注订阅号<偏执的喵喵>即可领取众多编程电子书籍哦![在这里插入图片描述](https://img-blog.csdnimg.cn/20200405090307934.png)\r\n\r\n', '2020-11-14 16:06:07', NULL, 0);
INSERT INTO `article` VALUES (2, 1, 9, '快排的递归实现', '# 快排的递归实现\r\n#### partition的几种实现\r\n第一个用首元素划分\r\n第二个用尾元素划分\r\n\r\n\r\n```cpp\r\n/*1.  使用while的partion*/\r\nint partition2(vector<int>&vec, int start, int end)\r\n{\r\n	int i = start, j = end;\r\n	int key = vec[start];\r\n	while (i < j)\r\n	{\r\n		while (i < j&&vec[j] >= key)\r\n			j--;\r\n		if (i < j)\r\n			vec[i++] = vec[j];\r\n		while (i < j&&vec[i] < key)\r\n			i++;\r\n		if (i < j)\r\n			vec[j--] = vec[i];\r\n	}\r\n	vec[i] = key;\r\n	return i;\r\n}\r\n\r\n\r\n\r\n/*2.  使用for的partion*/\r\nint partition1(vector<int>&vec, int start, int end)\r\n{\r\n	int key = vec[end];\r\n	int small = start - 1;\r\n	for (int i = start; i < end; i++)\r\n	{\r\n		if (vec[i] < vec[end]  )\r\n		{\r\n			small++;\r\n			swap(vec[small] , vec[i]);\r\n		}\r\n	}\r\n	small++;\r\n	swap(vec[small], vec[end]);\r\n	return small;\r\n}\r\n  \r\n\r\n\r\n```\r\n## 快排的解决代码\r\n\r\n\r\n```cpp\r\n//结合partition解决\r\nvoid quickSort(int a[], int p, int r) {\r\n  int position = 0;\r\n  if (p<r)\r\n  {\r\n    position = partition(a,p,r);//返回划分元素的最终位置\r\n    quickSort(a,p,position-1);//划分左边递归\r\n    quickSort(a, position + 1,r);//划分右边递归\r\n  }\r\n}\r\n\r\n\r\n//2.单独解决（为partion和sort的结合体）   可重点背诵\r\nvoid quick(int a[],int left,int right)\r\n{\r\n	if(left>=right)\r\n		return;\r\n	int i=left,j=right,key=a[left];\r\n	while(i<j)\r\n	{\r\n		while((i<j)&&a[j]>=key)\r\n			j--;\r\n		if(i<j)\r\n			a[i++]=a[j];\r\n		while((i<j)&&a[i]<key)\r\n			i++;\r\n		if(i<j)\r\n			a[j--]=a[i];\r\n	}\r\n	a[i]=key;\r\n	quick(a,left,j-1);\r\n	quick(a,j+1,right);\r\n}\r\n```\r\n\r\n如果想要性能提升，还可以使用随机作为划分\r\n\r\n```cpp\r\nint partition1(vector<int>&vec, int start, int end)\r\n{\r\n	int index = start+rand()%(end-start+1);//元素变化范围在[start,end] \r\n	swap(vec[index],vec[end]);\r\n	int small = start - 1;\r\n	for (int i = start; i < end; i++)\r\n	{\r\n		if (vec[i] < vec[end]  )\r\n		{\r\n			small++;\r\n			swap(vec[small] , vec[i]);\r\n		}\r\n	}\r\n	small++;\r\n	swap(vec[small], vec[end]);//此时[start,small-1]是比vec[end]小的 \r\n	                           // [small,end-1]全是比vec[end]大的\r\n								//交换small和end    即实现左小右大\r\n	return small;\r\n}\r\n```\r\n**码字不易   日后还会继续学习   想要与某211的沙雕一起学的话  关注一哈订阅号 <偏执的喵喵>    持续分享一些学习记录与众多电子书籍    想要算法章节上课的ppt也有哦**', '2020-11-14 16:06:35', NULL, 0);
INSERT INTO `article` VALUES (3, 1, 4, 'ssm配置流程', '# ssm配置流程\r\n参考：**b站狂神说java**\r\n**https://space.bilibili.com/95256449?spm_id_from=333.788.b_765f7570696e666f.1**\r\n\r\n#### 自动装配注解需要的config\r\n**context:annotation-config**\r\n1.如果想使用@ Resource 、@ PostConstruct、@ PreDestroy等注解就必须声明CommonAnnotationBeanPostProcessor。\r\n2.如果想使用@PersistenceContext注解，就必须声明PersistenceAnnotationBeanPostProcessor的Bean。\r\n3.如果想使用@Autowired注解，那么就必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。\r\n4.如果想使用 @Required的注解，就必须声明RequiredAnnotationBeanPostProcessor的Bean。\r\n\r\n**而使用context:annotation-config/ 就可以隐式地自动向Spring容器注册4个BeanPostProcessor**\r\n\r\n#### 理解三个注解的扫描或驱动\r\n1. <context:annotation-config /> 作用隐式的配置注解的加载类，默认的加载了AutowiredAnnotationBeanPostProcessor（autowired） ,@Resource、@PostConstruct、@PreDestroy等\r\n2.<mvc:annotation-driven/>  将reques 请求上面的数据绑定到controller 上\r\n3.<context:component-scan base-package=\"com.xiao.*\" />  自动扫描某个包下带有注解的类，并进行注解的相关操作，@Autowired 注入bean; **另外也包含了1 中所做的操作**\r\n\r\n\r\n\r\n\r\n## mybatis层  \r\n​创建项目\r\n##### ​导入依赖\r\n\r\n```xml\r\n<dependencies>\r\n  <!--Junit-->\r\n  <dependency>\r\n      <groupId>junit</groupId>\r\n      <artifactId>junit</artifactId>\r\n      <version>4.12</version>\r\n  </dependency>\r\n  <!--数据库驱动-->\r\n  <dependency>\r\n      <groupId>mysql</groupId>\r\n      <artifactId>mysql-connector-java</artifactId>\r\n      <version>8.0.19</version>\r\n  </dependency>\r\n  <!-- 数据库连接池 可选-->\r\n\r\n  <!--Servlet - JSP -->\r\n  <dependency>\r\n      <groupId>javax.servlet</groupId>\r\n      <artifactId>servlet-api</artifactId>\r\n      <version>2.5</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>javax.servlet.jsp</groupId>\r\n      <artifactId>jsp-api</artifactId>\r\n      <version>2.2</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>javax.servlet</groupId>\r\n      <artifactId>jstl</artifactId>\r\n      <version>1.2</version>\r\n  </dependency>\r\n\r\n  <!--Mybatis-->\r\n  <dependency>\r\n      <groupId>org.mybatis</groupId>\r\n      <artifactId>mybatis</artifactId>\r\n      <version>3.5.2</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>org.mybatis</groupId>\r\n      <artifactId>mybatis-spring</artifactId>\r\n      <version>2.0.2</version>\r\n  </dependency>\r\n\r\n  <!--Spring-->\r\n  <dependency>\r\n      <groupId>org.springframework</groupId>\r\n      <artifactId>spring-webmvc</artifactId>\r\n      <version>5.1.9.RELEASE</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>org.springframework</groupId>\r\n      <artifactId>spring-jdbc</artifactId>\r\n      <version>5.1.9.RELEASE</version>\r\n  </dependency>\r\n          <dependency>\r\n           <groupId>org.projectlombok</groupId>\r\n           <artifactId>lombok</artifactId>\r\n           <version>1.18.4</version>\r\n       </dependency>\r\n</dependencies>\r\n```\r\n##### 导入静态资源解析和java版本\r\n\r\n```xml\r\n<build>\r\n       <resources>\r\n           <resource>\r\n               <directory>src/main/java</directory>\r\n               <includes>\r\n                   <include>**/*.properties</include>\r\n                   <include>**/*.xml</include>\r\n               </includes>\r\n               <filtering>false</filtering>\r\n           </resource>\r\n           <resource>\r\n               <directory>src/main/resources</directory>\r\n               <includes>\r\n                   <include>**/*.properties</include>\r\n                   <include>**/*.xml</include>\r\n               </includes>\r\n               <filtering>false</filtering>\r\n           </resource>\r\n       </resources>\r\n       <plugins>\r\n           <plugin>\r\n               <groupId>org.apache.maven.plugins</groupId>\r\n               <artifactId>maven-compiler-plugin</artifactId>\r\n               <version>3.5</version>\r\n               <configuration>\r\n                   <source>1.8</source>\r\n                   <target>1.8</target>\r\n               </configuration>\r\n           </plugin>\r\n       </plugins>\r\n   </build>\r\n```\r\n##### 连接数据库		编写database.properties文件\r\n右侧直接添加  时区Asia/Shanghai\r\n\r\n```properties\r\njdbc.driver=com.mysql.cj.jdbc.Driver\r\njdbc.url=jdbc:mysql://localhost:3306/db1?useSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai\r\njdbc.username=root\r\njdbc.password=root\r\n```\r\n\r\n##### ​创建mybatis-config和applicationContext  创建实体类  \r\n**mybatis-config.xml**\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n<!DOCTYPE configuration\r\n       PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\"\r\n       \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\r\n<configuration>\r\n\r\n</configuration>\r\n```\r\n**applicationContext.xml**\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<beans xmlns=\"http://www.springframework.org/schema/beans\"\r\n      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n      xsi:schemaLocation=\"http://www.springframework.org/schema/beans\r\n       http://www.springframework.org/schema/beans/spring-beans.xsd\">\r\n\r\n</beans>\r\n```\r\n##### ​mybatis-config里写typealias取别名package      可添加日志\r\n\r\n```xml\r\n    <typeAliases>\r\n        <package name=\"com.mx.mapper\"/>\r\n    </typeAliases>\r\n```\r\n\r\n##### 写实体类，写dao的接口和***Mapper.xml文件\r\n自己写\r\n\r\n##### 写service的接口(函数直接复制dao接口的函数)  写service实现类(私有**Mapper成员和set方法以便注入)\r\n自己写\r\n## spring-dao层\r\n##### ​创建spring-dao.xml  添加到applicationContext.xml\r\n复制application.xml\r\n\r\n\r\n##### ​导入database.properties配置文件\r\njdbc.driver=com.mysql.cj.jdbc.Driver\r\njdbc.url=jdbc:mysql://localhost:3306/bookmanage?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai\r\njdbc.username=\r\njdbc.password=\r\n```xml\r\n<!--1. 关联数据库文件-->\r\n    <context:property-placeholder location=\"classpath:database.properties\"/>\r\n```\r\n\r\n##### 导入数据源(DriverManageDataSource)四信息\r\n复制application.xml\r\n\r\n\r\n##### ​注册SqlSessionFactory      需要注入数据源  注入configLocation为mybatis-config          还需要注入mapperLocation(作用是自动注册包下的mapper 就不用mybatis-config配置了)\r\n\r\n```xml\r\n<!--3. 注册sqlSessionFactory-->\r\n    <bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\">\r\n        <property name=\"dataSource\" ref=\"dataSource\"/>\r\n        <!-- 配置MyBaties全局配置文件:mybatis-config.xml -->\r\n        <property name=\"configLocation\" value=\"classpath:mybatis-config.xml\"/>\r\n    </bean>\r\n```\r\n\r\n##### ​配置dao接口扫描包，动态实现dao接口注册到spring  参数有SqlSessionFactoryBeanName  和需要的扫描的包basepackage\r\n\r\n```xml\r\n<!-- 4.配置扫描Dao接口包，动态实现Dao接口注入到spring容器中\r\n        即自动生成需要在service中注入的bean   在spring-service中注入进去\r\n    -->\r\n    <!--解释 ：https://www.cnblogs.com/jpfss/p/7799806.html-->\r\n    <bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\">\r\n        <property name=\"sqlSessionFactoryBeanName\" value=\"sqlSessionFactory\"/>\r\n        <!-- 给出需要扫描Dao接口包 -->\r\n        <property name=\"basePackage\" value=\"com.mx.mapper\"/>\r\n    </bean>\r\n```\r\n\r\n## spring-service层\r\n##### ​创建spring-service.xml  添加到applicationContext.xml\r\n复制application.xml\r\n\r\n##### 扫描service下的包context的component-scan   (@Service时使用附带用autowired)\r\n\r\n```xml\r\n    <!--1. 扫描service层的注解 spring特有注解  扫描**ServiceImpl的@service-->\r\n    <context:component-scan base-package=\"com.mx.service\" />\r\n\r\n```\r\n\r\n##### 注册serviceImpl的bean  需要参数**Mapper (如果没有使用注解的话才注册)\r\n自己写\r\n##### 声明事务   DataSourceTransactionManager            参数注入数据源   (在需要事务的方法上注解@Transactional的即开启事务)\r\n\r\n```xml\r\n    <tx:annotation-driven/>\r\n<bean id=\"transactionManager\" class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\">\r\n       <property name=\"dataSource\" ref=\"dataSource\" />\r\n   </bean>\r\n\r\n```\r\n\r\n## spring-mvc层\r\n##### ​添加web支持  切换到web.xml\r\n##### 注册DispatcherServlet(参数选择applicationContext.xml)\r\n\r\n```xml\r\n   <!--1. DispatcherServlet-->\r\n   <servlet>\r\n       <servlet-name>DispatcherServlet</servlet-name>\r\n       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>\r\n       <init-param>\r\n           <param-name>contextConfigLocation</param-name>\r\n           <!--一定要注意:这里加载的是总的配置文件，之前被这里坑了！-->\r\n           <param-value>classpath:applicationContext.xml</param-value>\r\n       </init-param>\r\n       <load-on-startup>1</load-on-startup>\r\n   </servlet>\r\n   <servlet-mapping>\r\n       <servlet-name>DispatcherServlet</servlet-name>\r\n       <url-pattern>/</url-pattern>\r\n   </servlet-mapping>\r\n```\r\n##### 注册乱码过滤器CharactorEncodingFilter\r\n\r\n```xml\r\n <!--2. encodingFilter-->\r\n    <filter>\r\n        <filter-name>encodingFilter</filter-name>\r\n        <filter-class>\r\n            org.springframework.web.filter.CharacterEncodingFilter\r\n        </filter-class>\r\n        <init-param>\r\n            <param-name>encoding</param-name>\r\n            <param-value>utf-8</param-value>\r\n        </init-param>\r\n    </filter>\r\n    <filter-mapping>\r\n        <filter-name>encodingFilter</filter-name>\r\n        <url-pattern>/*</url-pattern>\r\n    </filter-mapping>\r\n```\r\n\r\n##### 注册session过期时间\r\n\r\n```xml\r\n<!--3. Session过期时间-->\r\n   <session-config>\r\n       <session-timeout>15</session-timeout>\r\n   </session-config>\r\n```\r\n\r\n##### 创建spring-mvc.xml  添加到applicationContext.xml\r\n复制applicationContext.xml\r\n##### 切换到spring-mvc.xml\r\n##### ​注解驱动\r\n\r\n```xml\r\n    <!-- 1.开启SpringMVC注解驱动才可以使用@RequestMapping \r\n    	mvc特有-->\r\n    <mvc:annotation-driven />\r\n```\r\n##### 静态资源过滤\r\n\r\n```xml\r\n    <!-- 2.静态资源默认servlet配置-->\r\n    <mvc:default-servlet-handler/>\r\n```\r\n##### 视图解析器 InternalResourceViewResolver    参数是前后缀\r\n\r\n```xml\r\n<!-- 3.配置jsp 显示ViewResolver视图解析器 -->\r\n    <bean class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\">\r\n        <property name=\"viewClass\" value=\"org.springframework.web.servlet.view.JstlView\" />\r\n        <property name=\"prefix\" value=\"/WEB-INF/jsp/\" />\r\n        <property name=\"suffix\" value=\".jsp\" />\r\n    </bean>\r\n```\r\n##### component-scan扫描controller下的包\r\n\r\n```xml\r\n<!-- 4.扫描web相关的bean   这是spring特有注解扫描  让@Component生效 -->\r\n    <context:component-scan base-package=\"com.mx.controller\" />\r\n\r\n```\r\n\r\n\r\n## 末尾\r\n**配置Tomcat**\r\n## 务必\r\n**==​务必在structure里添加lib目录==\r\n​务必确认service层事务注解已经使用\r\n​全部import进入application**\r\n\r\n\r\n', '2020-11-14 16:10:02', 'http://qiniu.minxu.xyz/751ebe3d-f752-495e-9cfa-adf789a75384ssm.png', 0);
INSERT INTO `article` VALUES (4, 1, 3, 'ssm整合简化版', '# 固定配置\r\n## 对注解的理解\r\n#### 自动装配注解需要的config\r\n**context:annotation-config**\r\n1.如果想使用@ Resource 、@ PostConstruct、@ PreDestroy等注解就必须声明CommonAnnotationBeanPostProcessor。\r\n2.如果想使用@PersistenceContext注解，就必须声明PersistenceAnnotationBeanPostProcessor的Bean。\r\n3.如果想使用@Autowired注解，那么就必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。\r\n4.如果想使用 @Required的注解，就必须声明RequiredAnnotationBeanPostProcessor的Bean。\r\n**而使用context:annotation-config/ 就可以隐式地自动向Spring容器注册4个BeanPostProcessor**\r\n\r\n#### 理解三个注解的扫描或驱动\r\n1. <context:annotation-config /> 作用隐式的配置注解的加载类，默认的加载了AutowiredAnnotationBeanPostProcessor（autowired） ,@Resource、@PostConstruct、@PreDestroy等\r\n2.<mvc:annotation-driven/>  将reques 请求上面的数据绑定到controller 上\r\n3.<context:component-scan base-package=\"com.xiao.*\" />  自动扫描某个包下带有注解的类，并进行注解的相关操作，@Autowired 注入bean; **另外也包含了1 中所做的操作**\r\n\r\n\r\n\r\n## pom依赖and资源扫描and编译器版本\r\n```xml\r\n<dependencies>\r\n  <!--lombok-->\r\n	<dependency>\r\n       <groupId>org.projectlombok</groupId>\r\n       <artifactId>lombok</artifactId>\r\n       <version>1.18.4</version>\r\n   </dependency>\r\n  <!--Junit-->\r\n  <dependency>\r\n      <groupId>junit</groupId>\r\n      <artifactId>junit</artifactId>\r\n      <version>4.12</version>\r\n  </dependency>\r\n  <!--数据库驱动-->\r\n  <dependency>\r\n      <groupId>mysql</groupId>\r\n      <artifactId>mysql-connector-java</artifactId>\r\n      <version>8.0.19</version>\r\n  </dependency>\r\n  <!-- 数据库连接池 可选-->\r\n\r\n  <!--Servlet - JSP -->\r\n  <dependency>\r\n      <groupId>javax.servlet</groupId>\r\n      <artifactId>servlet-api</artifactId>\r\n      <version>2.5</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>javax.servlet.jsp</groupId>\r\n      <artifactId>jsp-api</artifactId>\r\n      <version>2.2</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>javax.servlet</groupId>\r\n      <artifactId>jstl</artifactId>\r\n      <version>1.2</version>\r\n  </dependency>\r\n\r\n  <!--Mybatis-->\r\n  <dependency>\r\n      <groupId>org.mybatis</groupId>\r\n      <artifactId>mybatis</artifactId>\r\n      <version>3.5.2</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>org.mybatis</groupId>\r\n      <artifactId>mybatis-spring</artifactId>\r\n      <version>2.0.2</version>\r\n  </dependency>\r\n\r\n  <!--Spring-->\r\n  <dependency>\r\n      <groupId>org.springframework</groupId>\r\n      <artifactId>spring-webmvc</artifactId>\r\n      <version>5.1.9.RELEASE</version>\r\n  </dependency>\r\n  <dependency>\r\n      <groupId>org.springframework</groupId>\r\n      <artifactId>spring-jdbc</artifactId>\r\n      <version>5.1.9.RELEASE</version>\r\n  </dependency>\r\n</dependencies>\r\n\r\n<build>\r\n       <resources>\r\n           <resource>\r\n               <directory>src/main/java</directory>\r\n               <includes>\r\n                   <include>**/*.properties</include>\r\n                   <include>**/*.xml</include>\r\n               </includes>\r\n               <filtering>false</filtering>\r\n           </resource>\r\n           <resource>\r\n               <directory>src/main/resources</directory>\r\n               <includes>\r\n                   <include>**/*.properties</include>\r\n                   <include>**/*.xml</include>\r\n               </includes>\r\n               <filtering>false</filtering>\r\n           </resource>\r\n       </resources>\r\n       <plugins>\r\n           <plugin>\r\n               <groupId>org.apache.maven.plugins</groupId>\r\n               <artifactId>maven-compiler-plugin</artifactId>\r\n               <version>3.5</version>\r\n               <configuration>\r\n                   <source>1.8</source>\r\n                   <target>1.8</target>\r\n               </configuration>\r\n           </plugin>\r\n       </plugins>\r\n   </build>\r\n```\r\n\r\n## mybatis-config.xml\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n<!DOCTYPE configuration\r\n        PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\"\r\n        \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\r\n<configuration>\r\n    \r\n    <typeAliases>\r\n        <package name=\"com.mx.pojo\"/>\r\n    </typeAliases>\r\n\r\n</configuration>\r\n```\r\n## applicationContext.xml\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<beans xmlns=\"http://www.springframework.org/schema/beans\"\r\n       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n       xsi:schemaLocation=\"http://www.springframework.org/schema/beans\r\n       http://www.springframework.org/schema/beans/spring-beans.xsd\">\r\n\r\n    <import resource=\"spring-dao.xml\"/>\r\n    <import resource=\"spring-service.xml\"/>\r\n    <import resource=\"spring-mvc.xml\"/>\r\n</beans>\r\n```\r\n## database.properties\r\n\r\n```cpp\r\njdbc.driver=com.mysql.cj.jdbc.Driver\r\njdbc.url=jdbc:mysql://localhost:3306/db1?useSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai\r\njdbc.username=root\r\njdbc.password=root\r\n```\r\n\r\n## spring-dao.xml\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<beans xmlns=\"http://www.springframework.org/schema/beans\"\r\n       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n       xmlns:context=\"http://www.springframework.org/schema/context\"\r\n       xsi:schemaLocation=\"http://www.springframework.org/schema/beans\r\n       http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd\">\r\n\r\n    <!--dao层如果 有mapple的实现类，则可以使用注解创建bean  在service层注入\r\n        不过已经可以动态实现  所以不需要扫描注解 -->\r\n\r\n\r\n    <!--1. 关联数据库文件-->\r\n    <context:property-placeholder location=\"classpath:database.properties\"/>\r\n\r\n    <!--2. 数据库连接池-->\r\n    <bean id=\"dataSource\" class=\"org.springframework.jdbc.datasource.DriverManagerDataSource\">\r\n        <property name=\"driverClassName\" value=\"${jdbc.driver}\"/>\r\n        <property name=\"url\" value=\"${jdbc.url}\"/>\r\n        <property name=\"username\" value=\"${jdbc.username}\"/>\r\n        <property name=\"password\" value=\"${jdbc.password}\"/>\r\n    </bean>\r\n    <!--3. 注册sqlSessionFactory-->\r\n    <bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\">\r\n        <property name=\"dataSource\" ref=\"dataSource\"/>\r\n        <!-- 配置MyBaties全局配置文件:mybatis-config.xml -->\r\n        <property name=\"configLocation\" value=\"classpath:mybatis-config.xml\"/>\r\n        <!-- 扫描model包 使用别名（此处在mybatis-config里取了别名） -->\r\n   		 <!-- <property name=\"typeAliasesPackage\" value=\"com.mx.pojo\"/>-->\r\n    </bean>\r\n\r\n\r\n    <!-- 4.配置扫描Dao接口包，动态实现Dao接口注入到spring容器中\r\n        即自动生成需要在service中注入的bean   在spring-service中注入进去\r\n    -->\r\n    <!--解释 ：https://www.cnblogs.com/jpfss/p/7799806.html-->\r\n    <bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\">\r\n        <property name=\"sqlSessionFactoryBeanName\" value=\"sqlSessionFactory\"/>\r\n        <!-- 给出需要扫描Dao接口包 -->\r\n        <property name=\"basePackage\" value=\"com.mx.mapper\"/>\r\n    </bean>\r\n\r\n</beans>\r\n```\r\n## spring-service.xml\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<beans xmlns=\"http://www.springframework.org/schema/beans\"\r\n       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n       xmlns:context=\"http://www.springframework.org/schema/context\"\r\n       xsi:schemaLocation=\"http://www.springframework.org/schema/beans\r\n       http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd\">\r\n\r\n    <!--1. 扫描service层的注解 如果有的话-->\r\n    <context:component-scan base-package=\"com.mx.service\" />\r\n\r\n    <!--2. 注册***ServiceImpl的bean  注入***Mapper-->\r\n    <bean id=\"studentService\" class=\"com.mx.service.StudentServiceImpl\">\r\n        <property name=\"studentMapper\" ref=\"studentMapper\"/>\r\n    </bean>\r\n\r\n    <!-- 3. 配置事务管理器   在需要事务的方法上使用@Transi。。。-->\r\n        <tx:annotation-driven/>\r\n    <bean id=\"transactionManager\" class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\">\r\n        <property name=\"dataSource\" ref=\"dataSource\" />\r\n    </bean>\r\n</beans>\r\n```\r\n\r\n## spring-mvc.xml\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<beans xmlns=\"http://www.springframework.org/schema/beans\"\r\n       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n       xmlns:context=\"http://www.springframework.org/schema/context\"\r\n       xsi:schemaLocation=\"http://www.springframework.org/schema/beans\r\n       http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd\">\r\n\r\n    <!-- 1.开启SpringMVC注解驱动 -->\r\n    <mvc:annotation-driven />\r\n    <!-- 2.静态资源默认servlet配置-->\r\n    <mvc:default-servlet-handler/>\r\n\r\n    <!-- 3.配置jsp 显示ViewResolver视图解析器 -->\r\n    <bean class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\">\r\n        <property name=\"viewClass\" value=\"org.springframework.web.servlet.view.JstlView\" />\r\n        <property name=\"prefix\" value=\"/WEB-INF/jsp/\" />\r\n        <property name=\"suffix\" value=\".jsp\" />\r\n    </bean>\r\n\r\n    <!-- 4.扫描web相关的bean -->\r\n    <context:component-scan base-package=\"com.mx.controller\" />\r\n</beans>\r\n```\r\n## web.xml\r\n\r\n```xml\r\n    <!--1. DispatcherServlet-->\r\n    <servlet>\r\n        <servlet-name>DispatcherServlet</servlet-name>\r\n        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>\r\n        <init-param>\r\n            <param-name>contextConfigLocation</param-name>\r\n            <!--一定要注意:这里加载的是总的配置文件，之前被这里坑了！-->\r\n            <param-value>classpath:applicationContext.xml</param-value>\r\n        </init-param>\r\n        <load-on-startup>1</load-on-startup>\r\n    </servlet>\r\n    <servlet-mapping>\r\n        <servlet-name>DispatcherServlet</servlet-name>\r\n        <url-pattern>/</url-pattern>\r\n    </servlet-mapping>\r\n\r\n    <!--2. encodingFilter-->\r\n    <filter>\r\n        <filter-name>encodingFilter</filter-name>\r\n        <filter-class>\r\n            org.springframework.web.filter.CharacterEncodingFilter\r\n        </filter-class>\r\n        <init-param>\r\n            <param-name>encoding</param-name>\r\n            <param-value>utf-8</param-value>\r\n        </init-param>\r\n    </filter>\r\n    <filter-mapping>\r\n        <filter-name>encodingFilter</filter-name>\r\n        <url-pattern>/*</url-pattern>\r\n    </filter-mapping>\r\n\r\n    <!--3. Session过期时间-->\r\n    <session-config>\r\n        <session-timeout>15</session-timeout>\r\n    </session-config>\r\n```\r\n\r\n## 温馨提示\r\nmybatis-config.xml需要修改包名\r\ndatabase.properties需要修改数据库信息\r\nspring-dao.xml只需要修改最下面的包名\r\nspring-service.xml修改1和2的包名\r\nspring-mvc.xml修改最后的包名', '2020-11-14 16:11:02', 'http://qiniu.minxu.xyz/1f4cc753-276b-4053-9008-bf8feb852276ssm.png', 0);
INSERT INTO `article` VALUES (5, 1, 2, '富文本editor.md的集成', '# 富文本editor.md的集成\r\n\r\n## 下载editor.md\r\nhttps://github.com/pandao/editor.md/archive/master.zip\r\n\r\n## examples目录\r\n在这个目录中有许多的md集成案例可以借鉴  特别是simple.html \r\n\r\n## 简单的集成使用\r\n此处的style.css为examples/simple.html引用的style.css我复制出来了\r\n**故需要自行修改路径  引入相应名字的即可**\r\n\r\ncss引入：\r\n~~~html\r\n    <!--editor.md-->\r\n    <link rel=\"stylesheet\" th:href=\"@{/lib/style.css}\" />\r\n    <link rel=\"stylesheet\" th:href=\"@{/lib/editormd.css}\"/>\r\n~~~\r\njs引入：\r\n~~~html\r\n<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->\r\n<script src=\"https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js\"></script>\r\n<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->\r\n<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js\"></script>\r\n\r\n<script th:src=\"@{/lib/editormd/js/jquery.min.js}\"></script>\r\n<script th:src=\"@{/lib/editormd/editormd.min.js}\"></script>\r\n<script type=\"text/javascript\">\r\n    var testEditor;\r\n\r\n    $(function () {\r\n        testEditor = editormd(\"test-editormd\", {\r\n            width: \"100%\",\r\n            height: 600,\r\n            syncScrolling: \"single\",\r\n            path: \"../lib/editormd/lib/\"\r\n        });\r\n    });\r\n</script>\r\n~~~\r\n集成截图\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200915204136702.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n\r\n## 实现md转html显示\r\n前端代码：\r\n~~~html\r\n<!DOCTYPE html>\r\n<html lang=\"en\" xmlns:th=\"http://www.thymeleaf.org\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>Title</title>\r\n\r\n    <!--editor.md-->\r\n    <link rel=\"stylesheet\" th:href=\"@{/lib/style.css}\" />\r\n    <link rel=\"stylesheet\" th:href=\"@{/lib/editormd.css}\"/>\r\n\r\n</head>\r\n<body>\r\n<div id=\"test-editormd-view\">\r\n    <textarea style=\"display:none;\" th:text=\"${content}\" name=\"test-editormd-markdown-doc\"></textarea>\r\n</div>\r\n\r\n<script src=\"https://cdn.bootcss.com/jquery/2.2.3/jquery.min.js\"></script>\r\n<script th:src=\"@{/editormd/lib/marked.min.js}\"></script>\r\n<script th:src=\"@{/editormd/lib/prettify.min.js}\"></script>\r\n<script th:src=\"@{/editormd/lib/raphael.min.js}\"></script>\r\n<script th:src=\"@{/editormd/lib/underscore.min.js}\"></script>\r\n<script th:src=\"@{/editormd/lib/sequence-diagram.min.js}\"></script>\r\n<script th:src=\"@{/editormd/lib/flowchart.min.js}\"></script>\r\n<script th:src=\"@{/editormd/lib/jquery.flowchart.min.js}\"></script>\r\n<script th:src=\"@{/editormd/editormd.js}\"></script>\r\n<script type=\"text/javascript\">\r\n    testEditormdView2 = editormd.markdownToHTML(\"test-editormd-view\", {\r\n        htmlDecode      : \"style,script,iframe\",  // you can filter tags decode\r\n        emoji           : true,\r\n        taskList        : true,\r\n        tex             : true,  // 默认不解析\r\n        flowChart       : true,  // 默认不解析\r\n        sequenceDiagram : true,  // 默认不解析\r\n    });\r\n</script>\r\n\r\n</body>\r\n</html>\r\n~~~\r\n**实现效果：**\r\n自动附带代码高亮效果\r\n\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200915204318101.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n## 实现图片上传功能\r\n上传配置\r\n~~~yml\r\n  servlet:\r\n    multipart:\r\n      max-file-size: 10MB\r\n      max-request-size: 10MB\r\n~~~\r\n\r\n前端代码\r\n~~~html\r\n	<!DOCTYPE html>\r\n<html lang=\"en\" xmlns:th=\"http://www.thymeleaf.org\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\r\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\r\n    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->\r\n\r\n    <!--editor.md-->\r\n    <link rel=\"stylesheet\" th:href=\"@{/lib/style.css}\" />\r\n    <link rel=\"stylesheet\" th:href=\"@{/lib/editormd.css}\"/>\r\n\r\n    <!-- Bootstrap -->\r\n    <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css\" rel=\"stylesheet\">\r\n\r\n    <link rel=\"stylesheet\" th:href=\"@{/css/me.css}\">\r\n    <title>后台</title>\r\n</head>\r\n<body>\r\n\r\n<div th:replace=\"~{commons::admin(\'blog\')}\"></div>\r\n\r\n<div class=\"container\">\r\n    <!--身体-->\r\n    <div class=\"container\" style=\"opacity: 0.9;\">\r\n        <form th:action=\"@{/admin/addArticle}\" method=\"post\" enctype=\"multipart/form-data\">\r\n            <div class=\"row text-left\" style=\"display: flex\">\r\n                <label>文章标题:</label>\r\n                <input name=\"title\" style=\"width: 25em\" class=\"form-control\"\r\n                       required placeholder=\"请输入标题...\" type=\"text\">\r\n                <label>封面图片:</label>\r\n                <input type=\"file\" name=\"file\">\r\n            </div>\r\n            <div class=\"row text-left\">\r\n                <label>选择标签:</label>\r\n                <label th:each=\"tag:${tags}\" class=\"checkbox-inline\">\r\n                    <input name=\"tags\" type=\"checkbox\" th:value=\"${tag.getId()}\"> <p th:text=\"${tag.getName()}\"></p>\r\n                </label>\r\n            </div>\r\n            <div class=\"row\">\r\n                <div id=\"layout\">\r\n                    <header>\r\n                        <h2>编辑博客</h2>\r\n                    </header>\r\n                    <div id=\"test-editormd\">\r\n                <textarea name=\"content\">[TOC]\r\n                #### Disabled options\r\n\r\n                - TeX (Based on KaTeX);\r\n                - Emoji;\r\n                - Task lists;\r\n                - HTML tags decode;\r\n                - Flowchart and Sequence Diagram;\r\n                </textarea>\r\n                    </div>\r\n                </div>\r\n            </div>\r\n            <div class=\"row text-right\">\r\n                <input type=\"submit\" class=\"btn btn-success\" style=\"width: 5em\">\r\n            </div>\r\n        </form>\r\n    </div>\r\n\r\n</div>\r\n\r\n\r\n\r\n<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->\r\n<script src=\"https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js\"></script>\r\n<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->\r\n<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js\"></script>\r\n\r\n<script th:src=\"@{/lib/editormd.min.js}\"></script>\r\n<script type=\"text/javascript\">\r\n    var testEditor;\r\n\r\n    $(function() {\r\n        testEditor = editormd(\"test-editormd\", {\r\n            width   : \"90%\",\r\n            height  : 600,\r\n            syncScrolling : \"single\",\r\n            //图片上传\r\n            imageUpload : true,\r\n            imageFormats : [\"jpg\", \"jpeg\", \"gif\", \"png\", \"bmp\", \"webp\"],\r\n            imageUploadURL : \"/admin/upload\",\r\n            onload : function() {\r\n                console.log(\'onload\', this);\r\n            },\r\n            path    : \"/editormd/lib/\"\r\n        });\r\n\r\n\r\n    });\r\n</script>\r\n\r\n</body>\r\n</html>\r\n~~~\r\n\r\n\r\n后端接收图片  ==返回格式必须一致==\r\n\r\n~~~java\r\n@RequestMapping(\"/upload\")\r\n    @ResponseBody\r\n    public HashMap<String, Object> upload(@RequestParam(\"editormd-image-file\") MultipartFile pic,Model model){\r\n        System.out.println(\"进入upload方法\");\r\n        String downloadPath=\"\";\r\n        if(pic.isEmpty()){\r\n            System.err.println(\"上传的图片为空\");\r\n        }\r\n        else{\r\n            // ResourceUtils.getURL(\"classpath:\") 是获取当前文件的resources路径\r\n            try {\r\n                // 获取文件的原始名称\r\n                String oldFileName = pic.getOriginalFilename();\r\n                String realPath = ResourceUtils.getURL(\"classpath:\").getPath() + \"static/files\";\r\n                // 处理文件上传\r\n                realPath=realPath.substring(1);\r\n                File file = new File(realPath);\r\n                if(!file.exists())\r\n                    file.mkdir();\r\n                System.out.println(realPath);\r\n                pic.transferTo(new File(realPath,oldFileName));\r\n                downloadPath=\"http://localhost:8084/files/\"+oldFileName;\r\n                System.out.println(\"downloadPath:http://localhost:8084/files/\"+oldFileName);\r\n            } catch (FileNotFoundException e) {\r\n                e.printStackTrace();\r\n            } catch (IOException e) {\r\n                e.printStackTrace();\r\n            }\r\n        }\r\n        HashMap<String, Object> map = new HashMap<>();\r\n        //必须返回此格式\r\n        map.put(\"url\",downloadPath);\r\n        map.put(\"success\", 1);\r\n        map.put(\"message\", \"upload success!\");\r\n\r\n        return map;\r\n    }\r\n   ~~~\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200928000115941.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n', '2020-11-14 16:13:34', 'http://qiniu.minxu.xyz/8de08749-4c90-4ece-a5b6-d973de87bd08editor.png', 0);
INSERT INTO `article` VALUES (6, 1, 2, 'druid集成于springboot', '# druid集成于springboot\r\n\r\n## 导入依赖\r\n~~~xml\r\n       <!--druid-->\r\n       <dependency>\r\n           <groupId>com.alibaba</groupId>\r\n           <artifactId>druid-spring-boot-starter</artifactId>\r\n           <version>1.1.21</version>\r\n       </dependency>\r\n~~~\r\n\r\n## yml中配置\r\n~~~yml\r\nspring:\r\n  datasource:\r\n    driver-class-name: com.mysql.cj.jdbc.Driver\r\n    url: jdbc:mysql://localhost:3306/blog?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC\r\n    username: blog\r\n    password: xxxxx\r\n    type: com.alibaba.druid.pool.DruidDataSource\r\n    druid:\r\n      initialSize: 5\r\n      minIdle: 5\r\n      maxActive: 20\r\n      maxWait: 60000\r\n      timeBetweenEvictionRunsMillis: 60000\r\n      minEvictableIdleTimeMillis: 300000\r\n      validationQuery: SELECT 1 FROM DUAL\r\n      testWhileIdle: true\r\n      testOnBorrow: false\r\n      testOnReturn: false\r\n      poolPreparedStatements: true\r\n      #   配置监控统计拦截的filters，去掉后监控界面sql无法统计，\'wall\'用于防火墙\r\n      filters: stat,wall,log4j\r\n      maxPoolPreparedStatementPerConnectionSize: 20\r\n      useGlobalDataSourceStat: true\r\n      connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500\r\n\r\nserver:\r\n  port: 8083\r\n\r\nmybatis-plus:\r\n  type-aliases-package: com.mx.pojo\r\n  mapper-locations: classpath:mybatis/mapper/*.xml\r\n~~~\r\n\r\n## 配置监控功能\r\n编写DruidConfig 配置类\r\n~~~java\r\npackage com.mx.config;\r\n\r\nimport com.alibaba.druid.pool.DruidDataSource;\r\nimport com.alibaba.druid.support.http.StatViewServlet;\r\nimport com.alibaba.druid.support.http.WebStatFilter;\r\nimport org.springframework.boot.context.properties.ConfigurationProperties;\r\nimport org.springframework.boot.web.servlet.FilterRegistrationBean;\r\nimport org.springframework.boot.web.servlet.ServletRegistrationBean;\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.Configuration;\r\n\r\nimport javax.sql.DataSource;\r\nimport java.util.Arrays;\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\n@Configuration\r\npublic class DruidConfig {\r\n\r\n    @ConfigurationProperties(prefix = \"spring.datasource\")\r\n    @Bean\r\n    public DataSource druid(){\r\n        return  new DruidDataSource();\r\n    }\r\n\r\n    //配置Druid的监控\r\n    //1、配置一个管理后台的Servlet\r\n    @Bean\r\n    public ServletRegistrationBean statViewServlet(){\r\n        ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), \"/druid/*\");\r\n        Map<String,String> initParams = new HashMap<>();\r\n\r\n        initParams.put(\"loginUsername\",\"admin\");\r\n        initParams.put(\"loginPassword\",\"123456\");\r\n        initParams.put(\"allow\",\"\");//默认就是允许所有访问\r\n        initParams.put(\"deny\",\"192.168.15.21\");//禁止某人访问\r\n\r\n        bean.setInitParameters(initParams);\r\n        return bean;\r\n    }\r\n\r\n\r\n    //2、配置一个web监控的filter\r\n    @Bean\r\n    public FilterRegistrationBean webStatFilter(){\r\n        FilterRegistrationBean bean = new FilterRegistrationBean();\r\n        bean.setFilter(new WebStatFilter());\r\n\r\n        Map<String,String> initParams = new HashMap<>();\r\n        initParams.put(\"exclusions\",\"*.js,*.css,/druid/*\");\r\n\r\n        bean.setInitParameters(initParams);\r\n\r\n        bean.setUrlPatterns(Arrays.asList(\"/*\"));\r\n\r\n        return  bean;\r\n    }\r\n}\r\n\r\n~~~\r\n### 使用监控功能\r\n访问http://localhost:8083/druid\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200915204933590.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n大功告成\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/2020091520503464.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n', '2020-11-14 16:15:15', NULL, 0);
INSERT INTO `article` VALUES (7, 1, 4, '文件上传springboot', '# 文件上传springboot\r\n前端\r\n~~~html\r\n<!DOCTYPE html>\r\n<html lang=\"en\" xmlns:th=\"http://www.thymeleaf.org\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>Title</title>\r\n</head>\r\n<body>\r\n<form th:action=\"@{/test1}\" method=\"post\" enctype=\"multipart/form-data\">\r\n    <input type=\"text\" name=\"name\">\r\n    <input type=\"text\" name=\"username\">\r\n    <input type=\"file\" name=\"file\">\r\n    <input type=\"submit\">\r\n</form>\r\n</body>\r\n</html>\r\n~~~\r\n\r\n\r\n后端\r\n\r\n~~~java\r\n  @RequestMapping(\"/test1\")\r\n    public String test1(User user, @RequestParam(\"file\") MultipartFile pic) {\r\n        System.out.println(\"接收到的\" + user);\r\n        System.out.println(\"进入了test方法\");\r\n\r\n\r\n        // ResourceUtils.getURL(\"classpath:\") 是获取当前文件的resources路径\r\n        try {\r\n            // 获取文件的原始名称\r\n            String oldFileName = pic.getOriginalFilename();\r\n            String realPath = ResourceUtils.getURL(\"classpath:\").getPath() + \"static/files\";\r\n            // 处理文件上传\r\n            realPath=realPath.substring(1);\r\n            File file = new File(realPath);\r\n            System.out.println(file.exists());\r\n            if(!file.exists())\r\n                file.mkdir();\r\n            System.out.println(realPath);\r\n            pic.transferTo(new File(realPath,oldFileName));\r\n            System.out.println(\"/files/\"+oldFileName);\r\n\r\n        } catch (FileNotFoundException e) {\r\n            e.printStackTrace();\r\n        } catch (IOException e) {\r\n            e.printStackTrace();\r\n        }\r\n\r\n        return \"redirect:/test\";\r\n    }\r\n~~~', '2020-11-14 16:15:41', NULL, 0);
INSERT INTO `article` VALUES (8, 1, 8, 'docker学习', '# docker安装常用软件\r\n### 安装mysql\r\n![](http://qiniu.minxu.xyz/51764efa-3dee-45d0-a1c6-33bfc6be78ddaQQ截图20201115002025.png)\r\n![](http://qiniu.minxu.xyz/609c8423-69d5-41c2-bb16-b629598b5e77aa20201115002140.png)\r\n\r\n~~~cmd\r\ndocker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:latest\r\n	#  -d 表示后台运行\r\n	#  -p 3306:3306 表示端口映射   不加只能内部访问 \r\n	# -e MYSQL_ROOT_PASSWORD=xxxxx 必须设定-e参数给定mysql的root密码\r\n	# --name xxxx   可以给定容器的名称（可选）\r\n	# 最后指定mysql   可以指定版本也可以不指定\r\n~~~\r\n### 安装redis\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200916173123702.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n### 安装nginx\r\n拷贝出来配置文件   运行时可以挂载进去\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200916220324550.png#pic_center)\r\n需要自行匹配挂载目录\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200916220609291.png#pic_center)\r\n\r\n# docker命令学习\r\ntips：镜像运行产生容器\r\n\r\n==centos查看防火墙状态==\r\n~~~cmd\r\nsystemctl status firewalld\r\n~~~\r\n==开启、重启、关闭、firewalld.service服务==\r\n~~~cmd\r\n# 开启\r\nservice firewalld start\r\n# 重启\r\nservice firewalld restart\r\n# 关闭\r\nservice firewalld stop\r\n~~~\r\n### 基础操作\r\n==docker启动命令==\r\n~~~cmd\r\nsystemctl start docker\r\n~~~\r\ntips：dockerhub是类似maven repository的  可以查看docker能下载的镜像\r\n\r\n==docker是cs架构   我们配置的都是客户端  服务端理应一直开启  此命令可以查看==\r\n~~~cmd\r\ndocker info\r\n~~~\r\n==查看有哪些镜像==\r\n~~~cmd\r\nsystemctl images									列出运行的镜像的信息\r\n	systemctl images -q							只列出运行的镜像的id\r\n	systemctl images -a							列出所有镜像（包括运行过的）\r\n	systemctl images -aq							所有运行过的id\r\n~~~\r\n==去dockerhub搜索需要下载的镜像==\r\n~~~cmd\r\ndocker search xxx\r\n~~~\r\n==下载镜像==\r\n~~~cmd\r\ndocker pull xxx\r\n	docker pull xxx:latest    					下载最新的版本\r\n	docker pull xxx:版本号   					下载相应的版本\r\n~~~\r\n==删除镜像==\r\n~~~cmd\r\ndocker rmi xxx\r\n	docker rmi xxx:版本号   					下载相应的版本\r\n	docker rmi xxx -f   							强制删除\r\n~~~\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200916132455468.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n\r\n\r\n### 容器操作\r\n==镜像运行就叫容器==\r\ndocker运行之后的容器相当与一台封装的虚拟机，需要内外端口映射\r\n~~~cmd\r\ndocker run -d -p 外部端口:内部端口 镜像名\r\n	-d的含义是守护进程运行  否则会占用当前终端\r\n	docker run -d --name 取的名字 -p 外部端口:内部端口 镜像名\r\n\r\n	docker run -p 外部端口:内部端口 镜像名\r\n		一般不这么运行:    docker run 镜像名    \r\n			提前一步docker images即可获得全部镜像名\r\n~~~\r\n==开启 关闭 重启 容器==\r\n~~~cmd\r\ndocker start	容器名或容器id   		id的前几个数字也可识别\r\ndocker stop 容器名或容器id   		id的前几个数字也可识别\r\ndocker restart 容器名或容器id   		id的前几个数字也可识别\r\n\r\n不建议 会丢失数据：\r\ndocker kill 容器名或容器id   		id的前几个数字也可识别\r\n~~~\r\n\r\n==查询运行的镜像==\r\n~~~cmd\r\ndocker ps\r\n~~~\r\n\r\n### docker进阶命令（背诵）\r\n> 进入容器内部终端\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200916133118854.png#pic_center)\r\n-it下面有解释，/bin/bash 表示当前终端   必须加上才能进行交互\r\n\r\n##### 镜像内部是ubuntu  如果需要安装东西 比如vi 需要：\r\n~~~cmd\r\n# 更新apt-get\r\napt-get upodate\r\n# 下载vim   因为该命令下载不了vi\r\napt-get install vim\r\n~~~\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200916132849494.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n\r\n# docker安装\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200915234534260.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n# docker的原理\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200915235041191.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200915234951256.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n# docker的阿里云加速服务\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200915235240681.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ1MTE3NjU1,size_16,color_FFFFFF,t_70#pic_center)\r\n执行右下的命令即可', '2020-11-14 16:21:59', 'http://qiniu.minxu.xyz/bfa0a869-4108-482f-a3fd-138c4e89ef68dockerQQ截图20201115001628.png', 0);
INSERT INTO `article` VALUES (9, 1, 5, 'springboot项目部署', '# springboot项目部署\r\n1. 打包项目\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200930191257635.png#pic_center)\r\n\r\n2.服务器的宝塔上务必设置数据库所有人访问\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200930192048698.png#pic_center)\r\n3. 上传jar包到服务器\r\n![在这里插入图片描述](https://img-blog.csdnimg.cn/20200930192340794.png#pic_center)\r\n\r\n4. 运行命令\r\n\r\n```\r\nnohup java -jar XXX.jar > Log.log 2>&1 & \r\n或者\r\nnohup java -jar XXX.jar >> Log.log 2>&1 & \r\n或者\r\nnohup java -jar XXX.jar > /dev/null 2>&1 & \r\n\r\n	# 查看情况\r\n	ps -ef|grep jar\r\n	# 停止jar\r\n	kill -9 -xxx\r\n\r\n```\r\n==命令说明==\r\n- 命令 \"nohup java -jar XXX.jar &\" 部分，表示不挂断运行命令,当账户退出或终端关闭时,程序仍然运行。注意，该作业的所有输出被重定向到nohup.out的文件中。\r\n- 命令 \"nohup java -jar XXX.jar > Log.log &\" 部分，表示不挂断运行命令,当账户退出或终端关闭时,程序仍然运行，并且该作业的所有输出被重定向到Log.log的文件中。“ > Log.log ” 该命令就是指定日志输出的文件。\r\n- \">>\"表示将输出以追加的方式重定向到Log.log中。\r\n\r\n- 标准输入文件(stdin)：stdin的文件描述符为0，Unix程序默认从stdin读取数据。\r\n- 标准输出文件(stdout)：stdout 的文件描述符为1，Unix程序默认向stdout输出数据。\r\n- 标准错误文件(stderr)：stderr的文件描述符为2，Unix程序会向stderr流中写入错误信息。\r\n- 屏蔽输出，起到禁止输出作用：/dev/null 是一个特殊的文件，写入到它的内容都会被丢弃；如果尝试从该文件读取内容，那么什么也读不到。但是 /dev/null 文件非常有用，将命令的输出重定向到它，会起到\"禁止输出\"的效果。\r\n- “> Log.log 2>&1” ：表示将 stdout 和 stderr 合并后重定向到 Log.log', '2020-11-14 16:18:37', 'http://qiniu.minxu.xyz/59a33a26-8963-4cbb-aa5e-2afc16c24ea3aaaa01115001821.png', 0);
COMMIT;

-- ----------------------------
-- Table structure for article_tag
-- ----------------------------
DROP TABLE IF EXISTS `article_tag`;
CREATE TABLE `article_tag` (
  `id` int NOT NULL AUTO_INCREMENT,
  `aid` int DEFAULT NULL,
  `tid` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `aid` (`aid`) USING BTREE,
  KEY `tid` (`tid`) USING BTREE,
  CONSTRAINT `article_tag_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `article` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `article_tag_ibfk_2` FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of article_tag
-- ----------------------------
BEGIN;
INSERT INTO `article_tag` VALUES (1, 1, 1);
INSERT INTO `article_tag` VALUES (2, 1, 2);
INSERT INTO `article_tag` VALUES (3, 2, 1);
INSERT INTO `article_tag` VALUES (4, 2, 2);
INSERT INTO `article_tag` VALUES (5, 3, 3);
INSERT INTO `article_tag` VALUES (6, 3, 4);
INSERT INTO `article_tag` VALUES (7, 4, 3);
INSERT INTO `article_tag` VALUES (8, 4, 4);
INSERT INTO `article_tag` VALUES (9, 5, 3);
INSERT INTO `article_tag` VALUES (10, 6, 3);
INSERT INTO `article_tag` VALUES (11, 6, 6);
INSERT INTO `article_tag` VALUES (12, 7, 3);
INSERT INTO `article_tag` VALUES (16, 9, 3);
INSERT INTO `article_tag` VALUES (17, 8, 3);
INSERT INTO `article_tag` VALUES (18, 8, 7);
INSERT INTO `article_tag` VALUES (19, 8, 8);
COMMIT;

-- ----------------------------
-- Table structure for attention
-- ----------------------------
DROP TABLE IF EXISTS `attention`;
CREATE TABLE `attention` (
  `id` int NOT NULL AUTO_INCREMENT,
  `masteruid` int DEFAULT NULL,
  `doneuid` int DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of attention
-- ----------------------------
BEGIN;
INSERT INTO `attention` VALUES (1, 2, 1);
COMMIT;

-- ----------------------------
-- Table structure for comment
-- ----------------------------
DROP TABLE IF EXISTS `comment`;
CREATE TABLE `comment` (
  `id` int NOT NULL AUTO_INCREMENT,
  `aid` int DEFAULT NULL COMMENT '评论所在文章',
  `name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评论者名字',
  `date` timestamp NULL DEFAULT NULL,
  `toname` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '被评论的名字',
  `content` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '评论内容',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `aid` (`aid`) USING BTREE,
  CONSTRAINT `comment_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `article` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of comment
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for star
-- ----------------------------
DROP TABLE IF EXISTS `star`;
CREATE TABLE `star` (
  `id` int NOT NULL AUTO_INCREMENT,
  `aid` int DEFAULT NULL,
  `uid` int DEFAULT NULL,
  `star` int DEFAULT '0',
  `agree` int DEFAULT '0',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `aid` (`aid`) USING BTREE,
  KEY `uid` (`uid`) USING BTREE,
  CONSTRAINT `star_ibfk_1` FOREIGN KEY (`aid`) REFERENCES `article` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `star_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of star
-- ----------------------------
BEGIN;
INSERT INTO `star` VALUES (1, 9, 1, 0, 1);
INSERT INTO `star` VALUES (2, 8, 1, 1, 0);
INSERT INTO `star` VALUES (3, 7, 1, 0, 1);
INSERT INTO `star` VALUES (4, 6, 1, 1, 0);
INSERT INTO `star` VALUES (5, 5, 1, 0, 1);
COMMIT;

-- ----------------------------
-- Table structure for tag
-- ----------------------------
DROP TABLE IF EXISTS `tag`;
CREATE TABLE `tag` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of tag
-- ----------------------------
BEGIN;
INSERT INTO `tag` VALUES (1, '数据结构');
INSERT INTO `tag` VALUES (2, '算法');
INSERT INTO `tag` VALUES (3, '微服务');
INSERT INTO `tag` VALUES (4, 'Spring');
INSERT INTO `tag` VALUES (5, '多线程');
INSERT INTO `tag` VALUES (6, '数据库');
INSERT INTO `tag` VALUES (7, '计算机基础');
INSERT INTO `tag` VALUES (8, '学习面试心得');
COMMIT;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户名称',
  `avatar` varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户头像',
  `username` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `password` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `introduction` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '暂无个人资料',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `user` VALUES (1, '我会jvav啊', 'http://qiniu.minxu.xyz/9542cc4c-fe85-4fe2-b569-736c70a2cfa71605231307715.jpeg', 'admin', 'mx', '中国地质大学（武汉） 软件工程');
INSERT INTO `user` VALUES (2, 'mx', 'http://qiniu.minxu.xyz/aae374fa-7ad4-4f29-a4ca-4320c6cd6a0dBB684A7BD946C58C010D4CC8D87381FF.jpg', 'mx', 'mx', '中国地质大学（未来城校区）');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
